function format(token, data) {
  let keys = Reflect.ownKeys(data)
  for (let i = 0; i < keys.length; i++) {
    let key = keys[i]
    let reg = new RegExp(`:${key}`, 'g')
    token = token.replace(reg, data[key])

  }

  return token
}
let data = {
  localDate: "2020-09-01",
  ip: "128.0.0.9",
  method: "POST",
  qunarglobal: "asdu2333wuroo",
  "nginx-ip": "100.90.98.109"
}
format(':ip - - [:localDate] ":method ":qunarglobal" [:nginx-ip] ":qunarglobal"', data)